package com.shopping.test;

import java.io.Serializable;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.jdbc.Work;
import org.hibernate.query.Query;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import com.shopping.entity.Dept;
import com.shopping.entity.Emp;

public class DeptTest1 {
			private SessionFactory sf;
			private Session session;
			private Transaction tx;
		    
			@Test
			public void Test(){
				String hql="select d.emps  from Dept d where d.deptno=2";
				Query query=session.createQuery(hql);
				List<Emp>list=query.list();
				for (Emp emp : list) {
					System.out.println(emp);
				}
			
			}
			
			
			
			
			
			
			
			@Before
			public void setUp(){
				sf=new Configuration().configure().buildSessionFactory();
				session=sf.openSession();
				tx=session.beginTransaction();
			}
			@After
			public void after(){
				tx.commit();
				if(session!=null){
					session.close();
				}
				if(sf!=null){
					sf.close();
				}
			}
}